from enum import Enum


class VIP(Enum):
    RED = 1
    YELLOW = 2
    GREEN = 3
    YELLOW_ALIAS = 2  # 相等的枚举会被当做第一个相同值的属性的别名


# # 枚举比较
# if VIP.RED.value == 1:
#     print('ok')
# else:
#     print('no')
#
#
# print(type(VIP.RED.name))
# print(VIP.RED.value)

# for key in VIP:  # 正常遍历不会输出别名枚举
#     print(key)
#
# for key in VIP.__members__:  # 输出全部枚举属性
#     print(key)
#
#
# for key in VIP.__members__.items():
#     print(key)
a = 1
print(VIP(a))  # 枚举转换

if VIP.RED == VIP(a):  # 枚举比较
    print("ok")
else:
    print("no")

from enum import IntEnum, unique  # 只能使用int类型的值


@unique  # 枚举的值不能有重复的
class VIP1(IntEnum):
    YELLOW = 1
    RED = 2
    BLUE = 3
    STR = "string"  # 会报错
